package com.songlanyun.modules.interact;

import com.songlanyun.modules.article.model.vo.UserPointVo;
import org.springframework.data.redis.core.BoundHashOperations;

import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public interface IInteractService {

    void browseSave(BoundHashOperations<String, String, Object> result);

    void likeSave(BoundHashOperations<String, String, Object> result);

    void shareSave(BoundHashOperations<String, String, Object> result);

    default List<UserPointVo>  mapToSortUserPointVoList(Map<String, Object> userMap)
    {
        return userMap.entrySet().stream().map(o -> new UserPointVo() {{
            setValue((Map<String, Object>) o.getValue());
            setUserId(Long.parseLong(o.getKey()));
        }}).sorted(Comparator.comparing(UserPointVo::getUserId)).collect(Collectors.toList());

    }
}
